﻿using Customer.API.Applcation.Command.RefundCommand;
using Customer.Infrstructre.ProcurementManager;
using MediatR;

namespace Customer.API.Applcation.CommandHandlers.RefundCommandHandler
{
    /// <summary>
    /// 销售退货删除
    /// </summary>
    public class RefundDelCommandHandler : IRequestHandler<RefundDelCommand, int>
    {
        IRefundRepository rRep;

        public RefundDelCommandHandler(IRefundRepository rRep)
        {
            this.rRep = rRep;
        }

        public async Task<int> Handle(RefundDelCommand request, CancellationToken cancellationToken)
        {
            //批删
            foreach (var item in request.RefundId)
            {
                var list = await rRep.GetModelAsync(item);
                list.IsDel = true;
                await rRep.Update(list);
            }
            return 1;
        }
    }
}
